package web.controller.user;

import common.consts.ContentType;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import service.BalanceService;
import service.ServiceResponse;
import web.Routes;
import web.controller.Base;
import web.security.Protection;

/**
 * Created by chen<chen@youjianghr.com> on 2015/7/17.
 * 资金余额
 *
 * @author chen<chen@youjianghr.com>
 */
@RestController
@RequestMapping(Routes.User.BALANCE)
public class Balance extends Base {

    private static final Logger LOGGER = LoggerFactory.getLogger(Balance.class);

    @Autowired
    BalanceService balanceService;

    @Protection
    @RequestMapping(method = RequestMethod.GET, produces = ContentType.JSON)
    public ServiceResponse mine() {
        long userId = getUserIdFromAuthHeader();

        return balanceService.getUserBalance(userId);
    }
}
